import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';

export const columns: BasicColumn[] = [
  {
    title: '订单号',
    dataIndex: 'orderId',
    width: 120,
    align: 'center',
  },
  {
    title: '预订时间',
    dataIndex: 'createTime',
    width: 120,
    align: 'center',
    customRender: ({ text }) => {
      // 2023 03 15 15 35 41
      return (
        text.substring(0, 4) +
        '-' +
        text.substring(4, 6) +
        '-' +
        text.substring(6, 8) +
        ' ' +
        text.substring(8, 10) +
        ':' +
        text.substring(10, 12) +
        ':' +
        text.substring(12, 14)
      );
    },
  },
  {
    title: '入住人',
    dataIndex: 'names',
    width: 80,
    align: 'center',
  },
  {
    title: '酒店城市',
    dataIndex: 'geoName',
    width: 80,
    align: 'center',
  },
  {
    title: '酒店名称',
    dataIndex: 'hotelName',
    width: 240,
    align: 'center',
  },
  {
    title: '入住日期',
    dataIndex: 'arrivalDate',
    width: 90,
    align: 'center',
  },
  {
    title: '离店日期',
    dataIndex: 'departureDate',
    width: 90,
    align: 'center',
  },
  {
    title: '房间数量',
    dataIndex: 'roomCount',
    width: 60,
    align: 'center',
  },
  {
    title: '房间类型',
    dataIndex: 'roomName',
    width: 100,
    align: 'center',
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 60,
    customRender: ({ text }) => {
      if (text === 'WAIT_CONFIRM') {
        return h(Tag, { color: 'red' }, () => '等待确认');
      } else if (text === 'WAIT_PAY') {
        return h(Tag, { color: 'yellow' }, () => '等待支付');
      } else if (text === 'CONFIRM') {
        return h(Tag, { color: 'green' }, () => '已确认');
      } else if (text === 'NO_SHOW') {
        return h(Tag, { color: 'green' }, () => '未入住');
      } else if (text === 'CHECK_OUT') {
        return h(Tag, { color: 'green' }, () => '已离店');
      } else if (text === 'CANCEL') {
        return h(Tag, { color: 'green' }, () => '已取消');
      } else if (text === 'CHECK_IN') {
        return h(Tag, { color: 'green' }, () => '已入住');
      } else if (text === 'INVALID') {
        return h(Tag, { color: 'green' }, () => '无效');
      }
    },
  },
  {
    title: '总房价',
    dataIndex: 'totalPay',
    width: 60,
    align: 'center',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'orderId',
    label: '订单编号',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: ' ',
      // prefix: '',
      style: 'width: 220px',
    },
  },
  {
    field: 'names',
    label: '入住人',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: ' ',
      // prefix: '乘机人：',
      style: 'width: 220px',
    },
  },
  {
    field: 'arrivalDate',
    component: 'RangePicker',
    label: '入住日期',
    colProps: {
      span: 6,
    },
    componentProps: {
      placeholder: ['入住日期起', '入住日期止'],
      style: 'width: 220px',
    },
  },
  {
    field: 'geoName',
    label: '入住城市',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: '',
      // prefix: '',
      style: 'width: 220px',
    },
  },
  {
    field: 'hotelName',
    label: '酒店名称',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      placeholder: ' ',
      // prefix: '',
      style: 'width: 220px',
    },
  },
  {
    field: 'status',
    label: '订单状态',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      placeholder: '',
      options: [
        { label: '已确认', value: 'CONFIRM' },
        { label: '未入住', value: 'NO_SHOW' },
        { label: '已入住', value: 'CHECK_IN' },
        { label: '已离店', value: 'CHECK_OUT' },
        { label: '已取消', value: 'CANCEL' },
      ],
      style: 'width: 220px',
    },
  },
];
